import { create } from "zustand";
import { Menu } from "../lib/api/system/menu.d";
import { getMenusApi } from "../lib/api/system";
import type { GetMenusApiResponse } from "@/lib/api/system.d";
interface MenuStore {
  menus: Menu[]; // 菜单
  getMenus: () => Promise<GetMenusApiResponse>; // 设置菜单
}

export const useMenuStore = create<MenuStore>((set) => ({
  menus: [],
  getMenus: async () => {
    const { data } = await getMenusApi();
    set({ menus: data });
    return data;
  },
}));
